package com.system.outpatientsystem.mapper;

import com.system.outpatientsystem.pojo.record_table;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RecordMapper {

    @Select("select * from record_table where id=#{Id}")
    record_table findById(Integer id);

    @Select("select * from record_table where user_id=#{userId}")
    List<record_table> findByUserId(Integer id);

    @Insert("INSERT INTO record_table(user_id, doctor_id, time,content, apply,formulation, formulation_price, pay_status, refund_status,visit_status)" +
            " VALUES (#{userId}, #{doctorId}, now(),#{content},#{apply},#{formulation}, #{formulationPrice}, #{payStatus},#{refundStatus}," +
            "#{visitStatus})")
    void add(record_table table);

    @Update("update record_table set user_id=#{userId}," +
            "doctor_id=#{doctorId}," +
            "time=now()," +
            "content=#{content}," +
            "apply=#{apply},"+
            "formulation=#{formulation}," +
            "formulation_price=#{formulationPrice}," +
            "pay_status=#{payStatus}," +
            "refund_status=#{refundStatus}," +
            "visit_status=#{visitStatus} where id=#{id}")
    void recordUpdate(record_table table);


}
